<? 
	include("../model/database.php");
	include("../model/xl_tim_dich_vu_dia_diem.php");
	include("../model/xl_binh_luan_dia_diem.php");
	include("../model/xl_hinh_anh_dia_diem.php");
	
	$xl_binh_luan = new xl_binh_luan_dia_diem();
	$xl_hinh_anh = new xl_hinh_anh_dia_diem();
	$xl_tim_kiem = new xl_tim_dich_vu_dia_diem();
	
	
	$last_id = $_POST['lastid'];
	$idquan = $_POST['idquan'];
	$idtinh = $_POST['idtinh'];
	
	
	$arrDDNext = $xl_tim_kiem->danhSachTimKiemQuanTinh_Viewmore($idquan,$idtinh,$last_id);

	$l = count($arrDDNext);
	$l_p = $arrDDNext[$l-1];
	$id_l = $l_p['MaDiaDiem'];
	
	foreach($arrDDNext as $row){
		$image = $xl_hinh_anh->hinhAnhDiaDiem($row['MaDiaDiem']);
		$hinhdaidien = $image[0]['DuongDan'];
		$sobinhluan = $xl_binh_luan->tong_binh_luan($row['MaDiaDiem']);
?>
	<div class="place-item"><!--một địa điểm-->
		<div class="place-avatar">
    
			<?
							if($hinhdaidien != ''){					
						?>
                        <a href="./?action=dia-diem&id=<?=$row['MaDiaDiem']?>&name=<?=$row['TenDiaDiem']?>">
                        <img src="uploads/place/<?=$hinhdaidien?>" alt="<?=$row['TenDiaDiem']?>">
                        </a>
						<? } else{?>
                        <a href="./?action=dia-diem&id=<?=$row['MaDiaDiem']?>&name=<?=$row['TenDiaDiem']?>">
                        	<img src="uploads/place/photo_not_available.png" alt="<?=$row['TenDiaDiem']?>">
                        </a>
                        <? }?>
                    </div>
                    <ul class="place-info">
                    	<li class="first">
                        	<a class="place-title" title="<?=$row['TenDiaDiem']?>" href="../controller/?action=dia-diem&amp;idPlace=<?=$row['MaDiaDiem']?>"><?=$row['TenDiaDiem']?></a>
			</li>
			<li>
			 <span class="address-details"><?=$row['DiaChi']?> - <?=$row['TenQuanHuyen']?> - <?=$row['TenTinhThanh']?></span>
			</li>
			<li>
                        <img class="icon" title="lượt xem" src="images/icon_views.png">
                        Lượt xem:
                        <span class="page-views"><?= number_format($row['SoLuotXem'],0,',',',')?></span>
                        </li>
                        <li>
                        <img class="icon" title="bình luận" src="images/icon_comment.png">
                        Bình luận:
                        <span class="comment-no"><?=number_format($sobinhluan,0,',',',')?></span>
                        </li>
		</ul>
		<div class="clear"></div>
	</div><!--[end] một địa điểm-->
	<?
	}
	if(count($arrDDNext)>=10)
	{
	?>
	<div class="place-item last" id="more<?=$id_l?>"><!--xem thêm-->
       <input type="hidden" id="idquan" name="idquan" value="<?=$idquan?>" />
      <input type="hidden" id="idtinh" name="idtinh" value="<?=$idtinh?>" />
        <a id="<?=$id_l?>" class="more">xem thêm</a>
        <div class="clear"></div>
    </div><!--[end] xem thêm-->
    <?
	}
    ?>